<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/style.css"/>">

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
<style>

	@keyframes bluePulse {
	from {
	     color: #00FF00; 
	     text-shadow: 0 0 10px #ebebeb; 
	}
	50% { 
	     color: #ffff00; 
	     text-shadow: 0 0 28px #2daebf; 
	}
	to {
		 color: #00FF00; 
		 text-shadow: 0 0 10px #ebebeb; 
	}
	}
	.cwb {
		animation-iteration-count: infinite;
		animation-name: bluePulse;
		animation-duration: 4s;
		position: relative;
		top:10px;
	}
	
	.title{
		transition: 0.5s;
		text-align:center;
		overflow: hidden;
		white-space: nowrap;
		font-size: 55px;
		line-height: 180px;
		font-weight:bold;
		letter-spacing: 15px;
		padding-left: 15px;
		font-family: '楷体';
	}
	input#J_codetext{
	     width: 35%;
	     position: absolute;
	     right: 100px;
	}
	
	canvas#myCanvas.J_codeimg{
	     position: relative;
	     left: 140px;
	     top: -20px;
	     width: 100px;
	     height: 100px;
	 
	}
	#mz:nth-of-type(odd){ background:#c6f9f7} /* odd 标识奇数行，even标识偶数行 */
	#mz:hover{ background: #E0F0F0;} /*鼠标悬停后表格背景颜色*/
	
</style>
<script type="text/javascript">
$(function(){
	
	//新建医疗卡
	$("#cybtn-new").linkbutton({onClick: function(){
		$('#sfxmNo').textbox("clear");	
		$('#sfxmName').textbox("clear");
		$('#sfxmMoney').numberbox('setValue',0.00);
		$('#mztfRefundableAmount').numberbox('setValue',0.00);
	}});

	//关闭医疗卡
	$("#cybtn-cancel").linkbutton({onClick: function(){
		$('#win-register').window('close');	
								
	}});
	
    //通过onChange动态联动设置名字和身份证
	$("#cyylkNo").combobox({onChange:function(n,o){
		$.getJSON('queryMedicalCardid',{
			'ylkno':n			
		},function(data){
			$("#cybName").textbox('setValue',data.brName);
	        $("#cybrIdcard").textbox('setValue',data.brIdcard);
	        $("#cybrSex").textbox('setValue',data.brSex);
	        $("#cybrAge").textbox('setValue',data.brAge);
	        $("#cy_Patient_data").window("open");
	        
		});   		
	}})
	
	//打开员工选择窗口
		$("#btn-cyemployees").linkbutton({onClick: function(){
			$('#cy-win-employees').window({
				'title' : "员工选择",
				'href' : "cy_his_employees"
			});
			$("#cy-win-employees").window("open");
			
		}}); 
    
	//打开浏览表单窗口
	$("#btn-register_print").linkbutton({onClick: function(){
		var ghno = $("#ghNo").textbox('getValue');
		var name = $("#cybName").textbox('getValue');
		var date = $("#cyghDate").datebox('getValue');
		var ylk = $("#cyylkNo").textbox('getValue');
		var idcard = $("#cybrIdcard").textbox('getValue');
		var type = $("#cyghType").combobox('getValue');
		var ks = $("#cyksName").combobox('getValue');
		var sex = $("#cybrSex").textbox('getValue');
		var age = $("#cybrAge").textbox('getValue');
		
		$('#cy-win-register_print').window({
			'title' : "浏览表单",
			'href' : "cy_register_print?ghNo="+ghno+"&brName="+
					name+"&ghDate="+date+"&ylkNo="
					+ylk+"&ghType="+type+"&ksName="
					+ks+"&cybrIdcard="+idcard
					+"&cybrSex="+sex+"&brAge="+age
			
		});
		$("#cy-win-register_print").window("open");
		
	}});
	
	
	//打开选择挂号窗口
	$("#cybtn-view").linkbutton({onClick: function(){
		$('#cy-win-Choose-register').window({
			'title' : "选择挂号",
			'href' : "cy_choose_register"
		});
		$("#cy-win-Choose-register").window("open");
		
		
	}}); 
	
    //表格双击 获取查询的值
	$('#cy_sfxm').datagrid({
		onDblClickRow:function(rowIndex,rowData){
			$("#sfxmNo").textbox('setValue',rowData.sfxmNo);
			$("#sfxmName").textbox('setValue',rowData.sfxmName);
			$("#sfxmMoney").numberbox('setValue',rowData.sfjlMoney);
			$("#cy_sfxm_open").window("open");
	    }
	});
	
	//动态添加表格获取查询的值
	$("#cycx_addsfxm").linkbutton({onClick:function(){
		var n = $("#sfxmNo").textbox('getValue');
		var m = $("#sfxmNo").textbox('getText');
		var mo = $("#sfxmMoney").textbox('getText');
		if(!m){
			$.messager.alert('His六医院','收费项目数据不完整，请核对，O(∩_∩)O谢谢','info');
		}else if(!mo){
			$.messager.alert('His六医院','请确认收费金额','info');
		}else{
			$.getJSON('cyquerysfxmid',{
				'sfxmNo':n			
			},function(data){
				var sfxmName = $("#sfxmName").textbox('getValue');
				var sfxmMoney = $("#sfxmMoney").numberbox('getValue');
		        $('#cycx_sfxm').datagrid('appendRow', {
					'sfjlType' : [data.sfjlType],
					'sfxmName' : sfxmName,
					'sfxmMoney' : sfxmMoney,
					'sfxmState' : [data.sfxmState],
					'sfjlDate':[data.sfjlDate],
					'sfjlDepartment':[data.sfjlDepartment]
				});
			});
		}
	}})
	
	//多行删除表格的数据
	$("#cy_btn_cancelsf").linkbutton({onClick:function(){
		var cyn = $("#cycx_sfxm").datagrid('getSelections');
		for(var i=0;i<cyn.length;i++){		
			
			var cynn = $("#cycx_sfxm").datagrid('getRowIndex',cyn[i]);
			$('#cycx_sfxm').datagrid('deleteRow',
					cynn);
		}
	}})
	

	
	//挂号处理
	$("#cy_btn_register").linkbutton({onClick:function(){
		var cyn = $("#cycx_sfxm").datagrid('getRows');
		var brName = $("#cybName").textbox('getText');
		var sfxmNo1 = $("#sfxmNo").textbox('getText');
		var sfxmName1 = $("#sfxmName").textbox('getText');
		var sfxmMoney1 = $("#sfxmMoney").textbox('getText');
		var ygName = $("#ygName").textbox('getText');
		if(!ygName){
			$.messager.alert('His六医院','经办人未选择，请核对，O(∩_∩)O谢谢','info');
		}
		 $("#form-registerAdd").form('submit', {
				url : 'registrationFormAdd',
				onSubmit : function() {
					//验证
					return $(this).form("validate");
				},
				success : function(data) {
					var json = eval("(" + data + ")");
					$('#cycl').combobox('setValue', '已处理');
					
					//删除加入收费数据					
					for(var i=0;i<cyn.length;i++){		
						
						var cynn = $("#cycx_sfxm").datagrid('getRowIndex',cyn[i]);
						$('#cycx_sfxm').datagrid('deleteRow',
								cynn);
					}
					
					$.messager.confirm('His六医院', '你好，请问是否打印挂号单？', function(r){
						if (r){
							$("#cy-win-register_print").window("open");	
						}
					})
				}
			});
	 if(!brName){
		 $.messager.confirm('His六医院', '病人姓名为空，请核对，是否继续?', function(r){			 
			if (r){
			 if(!sfxmNo1||!sfxmName1||!sfxmMoney1){
				$.messager.alert('His六医院','请加入挂号收费项目，O(∩_∩)O谢谢','info');
			 	$("#form-registerAdd").form('submit', {
					url : 'registrationFormAdd',
					onSubmit : function() {
						//验证
						return $(this).form("validate");
					},
					success : function(data) {
						var json = eval("(" + data + ")");
						
					}
				});
			 }	
				}
		   });
		
	    }
	}})
	
	
})
	//局部打印
	function printHtml(html){ 
	    var bodyHtml = document.body.innerHTML;
	    document.body.innerHTML=html;
	    window.print();
	    document.body.innerHTML=bodyHtml;		    
	}
	//调用局部打印方法
	function onprint(){
		var html = $("#printArea").html();
		$("#cy-win-register_print").window("close");
		printHtml(html);
		location.reload(true);
	}
</script>

<style>
     ol,li{
          float: left;
     }
     .mzh{
     	 overflow:hidden;
         height: 100%;       
     }
     #dg{
     border: 1px red solid;}
</style>
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'north',height:'35px',border:false">
			    <div class="btn-add">
			    	<a id="cybtn-new" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-add',width: '80px'">新建</a> 
			    		&nbsp;
			    		
			    	<a id="cybtn-view" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-open',width: '80px'">查看</a> 	
			    		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			    			
			    	<a style="position: relative;left: 140px;" id="cy_btn_register" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-handle',width: '80px'">挂号处理</a>
			    		&nbsp;
			    		
			    	<a style="position: relative;left: 270px;" id="btn-register_print" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-print',width: '80px'">打印</a>	
			    		&nbsp;
			    		
			    	<a style="position: relative;left: 280px;" id="cybtn-cancel" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-cancel',width: '80px'">取消</a>
			    				
			    </div>			    
			</div>	
			<div data-options="region:'center'">
				<form id="form-registerAdd" method="post">
					<div class="mzh" style="background: rgb(236,243,255);">
					     <ol>
					      	<li style="margin: 35px;">门诊号&nbsp;
					      		<input id="ghNo" readonly="readonly" value="${RegistrationFormId}" name="ghNo" class="easyui-textbox"
								data-options="width: 150"></li>
								
							<li style="margin: 35px;">状态&nbsp;
								<select readonly="readonly" name="ghState" class="easyui-combobox"  
					     		data-options="panelHeight: 'auto'" id="cycl"  style="width: 80px;">
								<option value="未处理">未处理</option>
								<option value="已处理">已处理</option>
								</select></li>
									
							<li style="margin: 35px;">挂号日期&nbsp;
								<input id="cyghDate" name="ghDate" value="new date" class="easyui-datebox"
								data-options="width: 150"></li>
							
							<li style="margin: -20px; position: relative;left: 63px;">卡号&nbsp;
								<select  id="cyylkNo" name="ylkNo" class="easyui-combobox"  
					     		data-options="
					     		url:'queryMedicalCardAll',
			                    valueField:'ylkNo',
			                    textField:'ylkNo',
			                    panelHeight:'auto'		              
			                    "style="width: 100px;">
								</select></li>
									
							<li style="margin: -20px; position: relative;left: 290px;">挂号类型&nbsp;
								<select id="cyghType" name="ghType" class="easyui-combobox"  
					     		data-options="
			                    panelHeight:'auto'
							    " style="width: 100px;">
							    <option>普通</option>
							    <option>急诊</option>
							    <option>专家</option>
								</select>
								</li>
									
							<li style="margin: -20px; position: relative;left: 515px;">科室&nbsp;
								<select id="cyksName" name="ksName" class="easyui-combobox"  
					     		data-options="
			                    panelHeight:'auto'"  
			                    style="width: 100px;">
			                    <option>内科</option>
			                    <option>外科</option>
			                    <option>妇科</option>
			                    <option>儿科</option>
			                    <option>中医科</option>
								</select>
								</li>
									
							<li style="margin: 20px;">病人姓名&nbsp;
								<input readonly="readonly" id="cybName" name="brName" class="easyui-textbox"
								data-options="width: 150"></li>	
								
							<li style="margin: 20px;">身份证号码&nbsp;
								<input readonly="readonly" id="cybrIdcard" name="brIdcard" class="easyui-textbox"
								data-options="width: 150"></li>	
								
							<li style="position: relative;top:20px">经办人&nbsp;
								<input readonly="readonly" id="ygName" name="ygName" class="easyui-textbox"
								data-options="width: 150">
								
								<a id="btn-cyemployees" class="easyui-linkbutton" 
				    			data-options="iconCls:'icon-three',plain:true"></a></li>	
											
					     </ol>
					</div>
				
			  <div id="tt" class="easyui-tabs" data-options="border:false,panelHeight:'auto'" style="width: 100%; height: 230px;">
	
					<div id="cy_btn_sfxm" title="收费项目">
						<table id="cy_sfxm" class="easyui-datagrid"
							data-options="
								url:'cyquerysfxm',
								fitColumns:true,
								fit:true,
								pagination: true,
								pageSize: 5,
								pageList: [5, 10, 15, 20],
								rownumbers: true,					
							    border: false
								">
							<thead>
								<tr>				
									<th data-options="field:'sfxmNo',width:'15%'">收费项目编号</th>
									<th data-options="field:'sfxmName',width:'15%'">收费项目名称</th>
								</tr>
							</thead>
						</table>
					</div>
	
					<div id="cy_sfxm_open" title="收费记录" style="height: 200px; overflow: hidden;">
						<div style="overflow: hidden;">
							<ol>
								<li style="padding: 5px;">收费项目&nbsp;
								
					      		<input id="sfxmNo" name="sfxmNo" class="easyui-textbox"
								data-options="width: 150">
								
								<input id="sfxmName" name="sfxmName" class="easyui-textbox"
								data-options="width: 150"></li>
								
								<li style="padding: 5px;margin: 45px;position: relative;right: 45px;bottom: 40px;">收挂号费&nbsp;
					      		
					      		<input id="sfxmMoney" value="0.00" name="sfxmMoney" class="easyui-numberbox"
								data-options="width: 100,precision:2">
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								
								退挂号费&nbsp;						
					      		<input id="cy_text_tghf" name="mztfRefundableAmount" value="0.00" class="easyui-numberbox"
								data-options="width: 100,precision:2">
								&nbsp;&nbsp;
								<a id="cycx_addsfxm" class="easyui-linkbutton" 
					    		data-options="iconCls:'icon-cy-charge',width: '80px'">加入收费</a> 
	
					    		<a id="cycx_tfsfxm" class="easyui-linkbutton" 
					    		data-options="iconCls:'icon-cy-refund',width: '80px'">加入退费</a> 
					    		
					    		<a style="position: relative;left: 88px;" id="cy_btn_cancelsf" class="easyui-linkbutton" 
					    		data-options="iconCls:'icon-cancel',width: '80px'">删除</a></li>
							</ol>	
						</div>
						
						<div style="height: 120px;position: relative;bottom: 80px;overflow: hidden;">				
							<table  id="cycx_sfxm" class="easyui-datagrid" 
							data-options="
									iconCls: 'icon-edit',							                
									width: '100%',
									border: false,
									height:'120px',
									pagination: true,
								    pageSize: 5,
								    pageList: [5, 10, 15, 20],
								    rownumbers: true,	
								">
							<thead>
								<tr>
									<th
										data-options="field:'sfjlType',width:'30%',editor:'textbox'">收费类型</th>
									<th
										data-options="field:'sfxmName',width:'30%',editor:'textbox'">收费项目</th>
									<th
										data-options="field:'sfjlDate',width:'10%',editor:'textbox'">收费日期</th>
									<th
										data-options="field:'sfxmMoney',width:'10%',editor:'textbox'">金额</th>
									<th
										data-options="field:'sfjlDepartment',width:'10%',editor:'textbox'">未状态</th>
									<th
										data-options="field:'sfxmState',width:'10%',editor:'textbox'">已状态</th>	
								</tr>
							</thead>
						</table>
					</div>		
			</div>
	
					<div id="cy_Patient_data" title="病人资料" data-options=""
						style="padding: 10px">
						
						<ol>
						<li style="padding: 5px;">病人性别&nbsp;						
				      		<select id="cybrSex" name="brSex" class="easyui-combobox"  
					     		data-options="panelHeight:'auto'"style="width: 100px;">
			                    <option>不详</option>
								</select>
							
							&nbsp;病人年龄&nbsp;						
				      		<input id="cybrAge" name="brAge" class="easyui-textbox"
							data-options="width: 150">
							
							&nbsp;婚姻状况&nbsp;						
				      		<select name="ygMaritalStatus" class="easyui-combobox"  
					     		data-options="panelHeight:'auto'"
					     		style="width: 100px;">
			                    <option>不详</option>
			                    <option>已婚</option>
			                    <option>未婚</option>
								</select>
							
						<li style="padding: 5px;">病状&nbsp;						
				      		<input id="sfxmNo" name="sfxmNo" class="easyui-textbox"
							data-options="width: 690,height:135"></li>
						</ol>			
					</div>	
				</div>		
				
				</form>
			</div>
		</div>
		
	<!-- 挂号管理员工窗口 -->
	<div id="cy-win-employees" class="easyui-window" title="选择员工"
		data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 500px; padding: 5px;">

	</div>	
	
	<!-- 挂号管理的选择挂号窗口 -->
	<div id="cy-win-Choose-register" class="easyui-window" title="选择挂号"
		data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 280px; padding: 5px;">

	</div>
	
	<!-- 挂号管理的打印预览窗口 -->
	<div id="cy-win-register_print" class="easyui-window" title="浏览表单"
		data-options="tools:'#dyyl',collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 500px; padding: 5px;">
		
		</div>
	
	<div id="dyyl">
    
	    <a href="#" title="打印" id='plan-printyl' class="icon-print" style="cursor: pointer;" onclick="onprint()"></a>

    </div>	
</body>
</html>